package com.hanbang.chu_xing_gao_zhao.view_find;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.hanbang.chu_xing_gao_zhao.application.HttpInterfaces;
import com.hanbang.chu_xing_gao_zhao.application.MyApplication;
import com.hanbang.chu_xing_gao_zhao.entity.FindMainData;
import com.hanbang.chu_xing_gao_zhao.myview.MorePopupWindowPublic_B;
import com.hanbang.chu_xing_gao_zhao.utils.BitmapUtil;
import com.hanbang.chu_xing_gao_zhao.utils.JsonHelper;
import com.hanbang.chu_xing_gao_zhao.utils.MyLog;
import com.hanbang.chu_xing_gao_zhao.utils.MyRequestCallBack;
import com.hanbang.chu_xing_gao_zhao.utils.MySharedPreferences;
import com.hanbang.chu_xing_gao_zhao.utils.MyToast;
import com.hanbang.chu_xing_gao_zhao.utils.SystemTools;
import com.hanbang.chu_xing_gao_zhao.utils.UiUtils;
import com.hanbang.chu_xing_gao_zhao.view_city_select.CitySelectActivity;
import com.hanbang.chu_xing_gao_zhao.view_dynamic.DynamicManageHome;
import com.hanbang.chu_xing_gao_zhao.view_find_classroom.FindClassroomFragmentActivity;
import com.hanbang.chu_xing_gao_zhao.view_find_esoterica.FindEsotericaActivity;
import com.hanbang.chu_xing_gao_zhao.view_find_standard.FindStandardClassifyActivity;
import com.hanbang.cxgz_2.R;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.client.HttpRequest;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 打大厨页面
 */
public class FindChefFragment extends Fragment implements OnClickListener {
    /**
     * 请求参数
     */
    private RequestParams params;
    /**
     * 瀑布流控件
     */
    private RecyclerView mRecyclerView;

    /**
     * 瀑布流数据集合
     */
    private ArrayList<FindMainData> listData = new ArrayList<FindMainData>();

    /**
     * 瀑布流适配器
     */
    private MyRecyclerViewAdapter adapter;
    /**
     * 宿主activity
     */
    private FindMainFragmentActivity findMainFragmentActivity;
//    private View view;
    /**
     * 页大小
     */
    private int pageSize = 10;
    /**
     * 第几页
     */
    private int pageIndex = 1;


    private String telphone;
    private String password;


    private int city_id = 0;
    private int Cuisines_id = 0;
    private int job_id = 0;
    private int age_min = 0;
    private int age_max = 0;
    private int order_by = 0;
    private int group_id = 1;


    public FindChefFragment() {

    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        findMainFragmentActivity = (FindMainFragmentActivity) getActivity();
        View view = inflater.inflate(R.layout.find_fragment, null);

        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initView();
        setOnClickListener();

    }

    /**
     * 初始化view
     * <p/>
     * <p/>
     * <p/>
     * pageSize：分页大小，可为空
     * pageIndex：当前页码，为空默认1
     * <p/>
     * group_id：组别，1为大厨，2为掌柜
     * <p/>
     * city_id：城市的id
     * Cuisines_id：菜系的id
     * job_id：职务、职位的id
     * age_min：年龄起始
     * age_max：年龄终止
     * order_by：排序，1为秘籍最多，2为粉丝最多，3为课程最多
     */
    private void initView() {
        telphone = MySharedPreferences.getSharedPreferencesKeyAndValue(getActivity(), MySharedPreferences.USER_DATA, "tlephone");
        password = MySharedPreferences.getSharedPreferencesKeyAndValue(getActivity(), MySharedPreferences.USER_DATA, "password");


        mRecyclerView = (RecyclerView) getView().findViewById(R.id.find_activity_recyclerView8888);
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        /**
         * 第一个参数，是控件列数或行数，第二参数是控制方向
         */
        mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));// 设置RecyclerView布局管理器为2列垂直排布
        adapter = new MyRecyclerViewAdapter(listData);
        mRecyclerView.setAdapter(adapter);


        params = new RequestParams();
        params.addBodyParameter("telphone", telphone);
        params.addBodyParameter("password", password);
        params.addBodyParameter("pageSize", pageSize + "");
        params.addBodyParameter("pageIndex", pageIndex + "");
        params.addBodyParameter("group_id", group_id + "");

        params.addBodyParameter("city_id", city_id + "");
        params.addBodyParameter("Cuisines_id", Cuisines_id + "");
        params.addBodyParameter("job_id", job_id + "");
        params.addBodyParameter("age_min", age_min + "");
        params.addBodyParameter("age_max", age_max + "");
        params.addBodyParameter("order_by", order_by + "");

        if (listData.size() == 0) {
            getHttpList(HttpInterfaces.MemberSelect, params);
        }


    }


    /**
     * 设置点击事件
     */
    private void setOnClickListener() {


        //瀑布item 的点击监听
        adapter.setOnClickListener(new OnItemClickListener() {
            @Override
            public void ItemClickListener(View view, int postion) {
                //因为加了一个头部所以位置要-1;
//                postion = postion - 1;

                DynamicManageHome.startOwn(findMainFragmentActivity, 0, true);


//                Intent intent = new Intent();
//                intent.setClass(getActivity(), FindClassroomDetailsActivity.class);
//                intent.putExtra("id", listData.get(postion).getId());
//                intent.putExtra("visitType", 5);
//                intent.putExtra("httpUtl", HttpInterfaces.Ketang_Details);
//                startActivity(intent);
            }

            @Override
            public void ItemLongClickListener(View view, int postion) {
            }
        });
    }

    /**
     * 监听处理
     */
    @Override
    public void onClick(View v) {

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        /**
         * 得到返回过来的城市
         */
        if (requestCode == 99 && resultCode == Activity.RESULT_OK) {

            String city = data.getStringExtra("city");
            city_id = Integer.parseInt(data.getStringExtra("cityId"));

            //得到城市Id
            MyLog.e("text", "cityId__" + city_id);
            ((TextView) ((LinearLayout) getView().findViewById(R.id.ll_bar_mid_conver_classify_city)).getChildAt(0)).setText(city);


            listData.clear();
            pageIndex = 1;
            params = new RequestParams();
            params.addBodyParameter("telphone", telphone);
            params.addBodyParameter("password", password);
            params.addBodyParameter("pageSize", pageSize + "");
            params.addBodyParameter("pageIndex", pageIndex + "");
            params.addBodyParameter("group_id", group_id + "");
            params.addBodyParameter("city_id", city_id + "");
            params.addBodyParameter("Cuisines_id", Cuisines_id + "");
            params.addBodyParameter("job_id", job_id + "");
            params.addBodyParameter("age_min", age_min + "");
            params.addBodyParameter("age_max", age_max + "");
            params.addBodyParameter("order_by", order_by + "");
            getHttpList(HttpInterfaces.MemberSelect, params);

        }
    }

    /**
     * 适配器
     */
    public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyViewHolderB> implements OnClickListener {
        // view的type：头部，内容，中部标题
        private static final int TYPE_HEADER = 1, TYPE_ITEM = 2, LOADING = 3;
        /**
         * 中部导航按钮-城市
         */
        private LinearLayout city;

        /**
         * 中部导航按钮-菜系
         */
        private LinearLayout styleOfCooking;

        /**
         * 中部导航按钮-职位
         */
        private LinearLayout position;

        /**
         * 中部导航按钮-年龄
         */
        private LinearLayout age;

        /**
         * 中部导航按钮-最热
         */
        private LinearLayout hottest;

        /**
         * 烹饪秘籍
         */
        private TextView esoterica;

        /**
         * 学习课堂
         */
        private TextView classroom;

        /**
         * 拜师
         */
        private TextView baiShi;

        /**
         * 餐饮标准化
         */
        private TextView standard;

        /**
         * 数据
         */
        private List<FindMainData> lists;
        /**
         * 加载
         */
        private TextView loading;

        private OnItemClickListener mListener;

        int old = -1;

        public MyRecyclerViewAdapter(List<FindMainData> lists) {

            findMainFragmentActivity.bitmapUtils = BitmapUtil.getBitmapUtils(getActivity(), MyApplication.bitmapCachePath);

            if (lists != null) {
                this.lists = lists;
            } else {
                this.lists = new ArrayList<FindMainData>();
            }

        }


        @Override
        public void onClick(View v) {
            Intent intent = new Intent();


            MorePopupWindowPublic_B popup = null;
            switch (v.getId()) {

                // 选择城市
                case R.id.ll_bar_mid_conver_classify_city:

                    intent.setClass(getActivity(), CitySelectActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    startActivityForResult(intent, 99);

                    break;
                // 菜系
                case R.id.ll_bar_mid_conver_gang_styleOfCooking:

                    popup = new MorePopupWindowPublic_B(getActivity(), findMainFragmentActivity.styleOfCookingList, 8, 100);
                    popup.showPopupWindow(styleOfCooking.getChildAt(0), 2);

                    break;
                // 职位
                case R.id.ll_bar_mid_conver_gang_position:
                    popup = new MorePopupWindowPublic_B(getActivity(), findMainFragmentActivity.positionList, 8, 200);

                    popup.showPopupWindow(position.getChildAt(0), 3);
                    break;
                // 年龄
                case R.id.bar_mid_age:
                    popup = new MorePopupWindowPublic_B(getActivity(), findMainFragmentActivity.ageArrayList, 8, 300);
                    popup.showPopupWindow(age.getChildAt(0), 2);

                    break;
                // 最热
                case R.id.ll_bar_mid_conver_classify_hottest:

                    popup = new MorePopupWindowPublic_B(getActivity(), findMainFragmentActivity.hottestList, 8, 400);
                    popup.showPopupWindow(hottest.getChildAt(0), 3);
                    break;
                // 烹饪秘籍
                case R.id.tv_find_activity_esoterica:
                    intent.setClass(getActivity(), FindEsotericaActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    startActivity(intent);
                    break;
                // 学习课堂
                case R.id.tv_find_activity_classroom:
                    intent.setClass(getActivity(), FindClassroomFragmentActivity.class);
                    intent.putExtra("type", "chef");
                    startActivity(intent);
                    break;
                // 我要拜师
                case R.id.tv_find_activity_baiShi:
                    intent.setClass(getActivity(), FindBaiShiActivity.class);
                    startActivity(intent);
                    break;
                // 餐饮标准化
                case R.id.tv_find_activity_standard:
                    intent.setClass(getActivity(), FindStandardClassifyActivity.class);
                    startActivity(intent);
                    break;

                default:

                    break;
            }

            // 点击监听的处理
            if (popup != null) {


                popup.setOnClickCallback(new MorePopupWindowPublic_B.OnClickCallback() {
                    @Override
                    public void onClick(MorePopupWindowPublic_B morePopWindow, int number, String content, int type) {

                        MyLog.i("text", "type__" + type + "number--" + number + "content" + content);
                        Toast.makeText(getActivity(), content, Toast.LENGTH_SHORT).show();

                        //菜系
                        if (type == 100) {
                            ((TextView) ((LinearLayout) getView().findViewById(R.id.ll_bar_mid_conver_gang_styleOfCooking)).getChildAt(0)).setText(content);
                            listData.clear();
                            Cuisines_id = number;
                            pageIndex = 1;
                            params = new RequestParams();
                            params.addBodyParameter("telphone", telphone);
                            params.addBodyParameter("password", password);
                            params.addBodyParameter("pageSize", pageSize + "");
                            params.addBodyParameter("pageIndex", pageIndex + "");
                            params.addBodyParameter("group_id", group_id + "");

                            params.addBodyParameter("city_id", city_id + "");
                            params.addBodyParameter("Cuisines_id", Cuisines_id + "");
                            params.addBodyParameter("job_id", job_id + "");
                            params.addBodyParameter("age_min", age_min + "");
                            params.addBodyParameter("age_max", age_max + "");
                            params.addBodyParameter("order_by", order_by + "");


                            getHttpList(HttpInterfaces.MemberSelect, params);

                        }
                        //职位
                        if (type == 200) {
                            ((TextView) ((LinearLayout) getView().findViewById(R.id.ll_bar_mid_conver_gang_position)).getChildAt(0)).setText(content);
                            listData.clear();
                            job_id = number;
                            pageIndex = 1;

                            params = new RequestParams();
                            params.addBodyParameter("telphone", telphone);
                            params.addBodyParameter("password", password);
                            params.addBodyParameter("pageSize", pageSize + "");
                            params.addBodyParameter("pageIndex", pageIndex + "");
                            params.addBodyParameter("group_id", group_id + "");

                            params.addBodyParameter("city_id", city_id + "");
                            params.addBodyParameter("Cuisines_id", Cuisines_id + "");
                            params.addBodyParameter("job_id", job_id + "");
                            params.addBodyParameter("age_min", age_min + "");
                            params.addBodyParameter("age_max", age_max + "");
                            params.addBodyParameter("order_by", order_by + "");
                            getHttpList(HttpInterfaces.MemberSelect, params);


                        }
                        //年龄
                        if (type == 300) {
                            ((TextView) ((LinearLayout) getView().findViewById(R.id.bar_mid_age)).getChildAt(0)).setText(content);

                            listData.clear();
                            pageIndex = 1;

                            if (content.equals("不限")) {
                                age_min = 0;
                                age_max = 0;
                            } else if (content.equals("18岁以下")) {
                                age_min = -1;
                                age_max = 18;
                            } else if (content.equals("55岁以上")) {
                                age_min = 55;
                                age_max = -1;
                            } else {
                                age_min = Integer.parseInt(content.substring(0, 2));
                                age_max = Integer.parseInt(content.substring(3, 5));

                            }

                            MyLog.i("text", "\nage_min" + age_min + "\nage_max--" + age_max);

                            params = new RequestParams();
                            params.addBodyParameter("telphone", telphone);
                            params.addBodyParameter("password", password);
                            params.addBodyParameter("pageSize", pageSize + "");
                            params.addBodyParameter("pageIndex", pageIndex + "");
                            params.addBodyParameter("group_id", group_id + "");

                            params.addBodyParameter("city_id", city_id + "");
                            params.addBodyParameter("Cuisines_id", Cuisines_id + "");
                            params.addBodyParameter("job_id", job_id + "");
                            params.addBodyParameter("age_min", age_min + "");
                            params.addBodyParameter("age_max", age_max + "");
                            params.addBodyParameter("order_by", order_by + "");

                            getHttpList(HttpInterfaces.MemberSelect, params);

                        }
                        //最热
                        if (type == 400) {
                            ((TextView) ((LinearLayout) getView().findViewById(R.id.ll_bar_mid_conver_classify_hottest)).getChildAt(0)).setText(content);

                            listData.clear();
                            order_by = number;
                            pageIndex = 1;
                            params = new RequestParams();
                            params.addBodyParameter("telphone", telphone);
                            params.addBodyParameter("password", password);
                            params.addBodyParameter("pageSize", pageSize + "");
                            params.addBodyParameter("pageIndex", pageIndex + "");
                            params.addBodyParameter("group_id", group_id + "");

                            params.addBodyParameter("city_id", city_id + "");
                            params.addBodyParameter("Cuisines_id", Cuisines_id + "");
                            params.addBodyParameter("job_id", job_id + "");
                            params.addBodyParameter("age_min", age_min + "");
                            params.addBodyParameter("age_max", age_max + "");
                            params.addBodyParameter("order_by", order_by + "");
                            getHttpList(HttpInterfaces.MemberSelect, params);

                        }


                    }

                });

            }
        }

        public void setOnClickListener(OnItemClickListener listener) {
            this.mListener = listener;
        }

        @Override
        public MyViewHolderB onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = null;
            // 根据类型填充不同布局
            switch (viewType) {
                //添加头部
                case TYPE_HEADER:
                    view = LayoutInflater.from(getActivity()).inflate(R.layout.find_fragment_title, parent, false);


                    esoterica = (TextView) view.findViewById(R.id.tv_find_activity_esoterica);
                    classroom = (TextView) view.findViewById(R.id.tv_find_activity_classroom);
                    baiShi = (TextView) view.findViewById(R.id.tv_find_activity_baiShi);
                    standard = (TextView) view.findViewById(R.id.tv_find_activity_standard);


                    city = (LinearLayout) view.findViewById(R.id.ll_bar_mid_conver_classify_city);
                    styleOfCooking = (LinearLayout) view.findViewById(R.id.ll_bar_mid_conver_gang_styleOfCooking);
                    position = (LinearLayout) view.findViewById(R.id.ll_bar_mid_conver_gang_position);
                    age = (LinearLayout) view.findViewById(R.id.bar_mid_age);
                    hottest = (LinearLayout) view.findViewById(R.id.ll_bar_mid_conver_classify_hottest);


                    city.setOnClickListener(this);
                    styleOfCooking.setOnClickListener(this);
                    position.setOnClickListener(this);
                    age.setOnClickListener(this);
                    hottest.setOnClickListener(this);

                    esoterica.setOnClickListener(this);
                    classroom.setOnClickListener(this);
                    baiShi.setOnClickListener(this);
                    standard.setOnClickListener(this);


                    break;
                //内容
                case TYPE_ITEM:
                    view = LayoutInflater.from(getActivity()).inflate(R.layout.item_find_activity_recycleview, parent, false);
                    break;

                //加载更多
                case LOADING:

                    view = LayoutInflater.from(getActivity()).inflate(R.layout.list_foot_loading, parent, false);
                    loading = (TextView) view.findViewById(R.id.tv_list_foot_loading);
                    loading.setOnClickListener(this);
            }

            //更改字体
            UiUtils.applyFont(view);
            MyViewHolderB viewHolder = new MyViewHolderB(view);
            return viewHolder;
        }


        @Override
        public void onBindViewHolder(final MyViewHolderB holder, int position) {
            switch (holder.getItemViewType()) {
                //使用头单独占一行
                case TYPE_HEADER:
                    // 最最关键一步，设置当前view占满列数，这样就可以占据两列实现头部了
                    StaggeredGridLayoutManager.LayoutParams clp = (StaggeredGridLayoutManager.LayoutParams) holder.head.getLayoutParams();
                    /**
                     * 如果设置为true，该项目将布局采用全量程范围。这意味着，如果方向
                      *是垂直的，认为将有充分的宽度;如果方向是水平的，视图将
                      *有充分的高度。
                       *参数fullSpan如果此项目应遍历所有的跨度。
                     */
                    clp.setFullSpan(true);

                    break;
                //内容的展示
                case TYPE_ITEM:
                    if (lists.size() == 0 || lists.size() < position) {
                        return;
                    }
                    //因为传过来的position是从0开始，所以要减1.
                    position = position - 1;

                    ViewGroup.LayoutParams params = holder.itemView.getLayoutParams();// 得到item的LayoutParams布局参数

                    holder.itemView.setLayoutParams(params);// 把params设置给item布局

                    findMainFragmentActivity.bitmapUtils.configDefaultLoadFailedImage(R.drawable.default_white);

                    findMainFragmentActivity.bitmapUtils.display(holder.picture, SystemTools.getHttpFileUrl(lists.get(position).getAvatar()));


                    holder.name.setText(lists.get(position).getUser_name());
                    holder.beGoodAt.setText("擅长:"+lists.get(position).getCuisinesName());
                    holder.fans.setText("粉丝:" + lists.get(position).getMembershipcount());
                    holder.esotarica.setText("秘籍:" + lists.get(position).getMijicount());

                    holder.attentionText.setText("关注");
                    holder.attention.setOnClickListener(this);


                    //设置item 的监听
                    if (mListener != null) {// 如果设置了监听那么它就不为空，然后回调相应的方法
                        /**
                         * 点击监听
                         */
                        holder.itemView.setOnClickListener(new OnClickListener() {

                            public void onClick(View v) {
                                int pos = holder.getPosition();// 得到当前点击item的位置pos
                                mListener.ItemClickListener(holder.itemView, pos);// 把事件交给我们实现的接口那里处理


                            }
                        });

                        /**
                         * 长按监听
                         */
                        holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
                            @Override
                            public boolean onLongClick(View v) {
                                int pos = holder.getPosition();// 得到当前点击item的位置pos
                                mListener.ItemLongClickListener(holder.itemView, pos);// 把事件交给我们实现的接口那里处理
                                return true;
                            }
                        });
                    }


                    break;


                //使用尾部独占一行
                case LOADING:

                    //如果没有新的数据则隐藏加载按键
                    if (lists.size() == old) {
                        holder.bottom.setVisibility(View.GONE);
                        return;
                    } else {
                        holder.bottom.setVisibility(View.VISIBLE);
                    }
                    //加载尾部布局
                    StaggeredGridLayoutManager.LayoutParams clp1 = (StaggeredGridLayoutManager.LayoutParams) holder.bottom.getLayoutParams();
                    clp1.setFullSpan(true);

                    //自动加载
                    if (position - 1 == listData.size()) {

                        if (old == lists.size()) {
                            return;
                        }
                        ++pageIndex;


                        RequestParams paramsA = new RequestParams();
                        paramsA.addBodyParameter("telphone", telphone);
                        paramsA.addBodyParameter("password", password);
                        paramsA.addBodyParameter("pageSize", pageSize + "");
                        paramsA.addBodyParameter("pageIndex", pageIndex + "");
                        paramsA.addBodyParameter("group_id", group_id + "");

                        paramsA.addBodyParameter("city_id", city_id + "");
                        paramsA.addBodyParameter("Cuisines_id", Cuisines_id + "");
                        paramsA.addBodyParameter("job_id", job_id + "");
                        paramsA.addBodyParameter("age_min", age_min + "");
                        paramsA.addBodyParameter("age_max", age_max + "");
                        paramsA.addBodyParameter("order_by", order_by + "");

                        getHttpList(HttpInterfaces.MemberSelect, paramsA);

                        old = lists.size();

                    }


                    break;

            }
        }

        @Override
        public int getItemCount() {
            return lists.size() + 1;
        }

        @Override
        public int getItemViewType(int position) {
            //添加一个底部加载使用
            if (position == lists.size() + 1 && lists.size() > 1) {
                return LOADING;
            }

            // 位置为0的话类型为头部，其余为内容
            return position = position == 0 ? TYPE_HEADER : TYPE_ITEM;
        }
    }


    /**
     * 内容控件的初始化
     */
    class MyViewHolderB extends RecyclerView.ViewHolder implements OnClickListener {
        public ImageView picture;
        public TextView name;
        public TextView beGoodAt;//擅长
        public TextView fans;//粉丝
        public TextView esotarica;//秘籍
        public TextView attentionText;//关注文本
        public LinearLayout attention;//关注

        public LinearLayout head;
        public LinearLayout bottom;


        public MyViewHolderB(View itemView) {
            super(itemView);
            //头部
            if (itemView.getId() == R.id.find_fragment_title) {
                head = (LinearLayout) itemView.findViewById(R.id.find_fragment_title);
                //底部加载
            } else if (itemView.getId() == R.id.ll_list_foot_loading_parent) {
                bottom = (LinearLayout) itemView.findViewById(R.id.ll_list_foot_loading_parent);

                //内容
            } else {
                picture = (ImageView) itemView.findViewById(R.id.lv_item_find_activity_recyclerViewv_picture);
                name = (TextView) itemView.findViewById(R.id.tv_item_find_activity_recyclerView_name);

                beGoodAt = (TextView) itemView.findViewById(R.id.tv_item_find_activity_recyclerView_beGoodAt);
                fans = (TextView) itemView.findViewById(R.id.tv_item_find_activity_recyclerView_fans);
                esotarica = (TextView) itemView.findViewById(R.id.tv_item_find_activity_recyclerView_esoteroca);
                attentionText = (TextView) itemView.findViewById(R.id.tv_item_find_activity_recyclerView_attention);
                attention = (LinearLayout) itemView.findViewById(R.id.ll_item_find_activity_recyclerView_attention);
            }
        }

        @Override
        public void onClick(View v) {

        }
    }


    /**
     * 定义回调接口
     */
    interface OnItemClickListener {
        void ItemClickListener(View view, int postion);

        void ItemLongClickListener(View view, int postion);
    }


    /**
     * 获取网络列表
     */
    private void getHttpList(String url, RequestParams params) {
        findMainFragmentActivity.httpUtils.send(HttpRequest.HttpMethod.POST, url, params, new MyRequestCallBack<String>(getActivity(), "加载中...") {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                super.onSuccess(responseInfo);
                try {
                    JSONObject json = new JSONObject(responseInfo.result);
                    MyLog.i("text", "7777" + listData.toString());

                    int result = json.getInt("Result");
                    if (result == 0) {
                        JSONArray jsonArray1 = json.getJSONArray("list");

                        if (jsonArray1.length() == 0) {
                            MyToast.show(getActivity(), "没有更多内容", 1);
                            adapter.notifyDataSetChanged();
                            return;
                        }


                        // 把数据从接口解析出来
                        listData.addAll(JsonHelper.parseCollection(jsonArray1, ArrayList.class, FindMainData.class));
//                        MyLog.i("text", "555*****" + listData.toString());


                    }

                    MyLog.i("text", "888888" + listData.toString());

                    adapter.notifyDataSetChanged();

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }


}
